// $codepro.audit.disable
/**
 * 
 */
package edu.gatech.oad.doctorsorder;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;



import org.junit.Before;
import org.junit.Test;

import edu.gatech.oad.user.Doctor;
import edu.gatech.oad.user.Nurse;
import edu.gatech.oad.user.Receptionist;
import edu.gatech.oad.user.User;

/**
 * Test case for searchController
 * 
 * @author chen
 *
 */
public class SearchControllerTest {
	List<User> list;
	List<User> zeroList;
	SearchController sc;
	SearchController sc1;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		//create a user list
		list=new ArrayList<User>();
		User tmp=new Doctor("doc");
		tmp.setFirstName("docF");
		tmp.setLastName("docL");
		list.add( tmp);
		tmp=new Nurse("nurse");
		tmp.setFirstName("nurseF");
		tmp.setLastName("nurseL");
		list.add(tmp);
		tmp=new Receptionist("recep");
		tmp.setFirstName("recepF");
		tmp.setLastName("recepL");
		list.add(tmp);
		sc=new SearchController(list);
		
		//create an empty list
		zeroList=new ArrayList<User>();
		sc1=new SearchController(zeroList);
	}

	/**
	 * Test method for {@link edu.gatech.oad.doctorsorder.SearchController#search(java.lang.String)}.
	 */
	@Test
	public void testSearch() {
		//search for doc
		assertEquals("docF",sc.search("doc").get(0).getFirstName() );
		
		//search for nurse
		assertEquals("nurseL", sc.search("nurse").get(0).getLastName());
		
		//search for recep
		assertEquals("recepF", sc.search("recep").get(0).getFirstName());
		
		//search for something not exists
		assertEquals(0, sc.search("abc").size());
		
		//search for empty string
		assertEquals(0, sc.search("abc").size());
		
		//search in empty list
		assertEquals(0, sc.search("abc").size());
	}

}
